/* Copyright (c) 2007  Peter Palotas
 *  
 *  This software is provided 'as-is', without any express or implied
 *  warranty. In no event will the authors be held liable for any damages
 *  arising from the use of this software.
 *  
 *  Permission is granted to anyone to use this software for any purpose,
 *  including commercial applications, and to alter it and redistribute it
 *  freely, subject to the following restrictions:
 *  
 *      1. The origin of this software must not be misrepresented; you must not
 *      claim that you wrote the original software. If you use this software
 *      in a product, an acknowledgment in the product documentation would be
 *      appreciated but is not required.
 *  
 *      2. Altered source versions must be plainly marked as such, and must not be
 *      misrepresented as being the original software.
 *  
 *      3. This notice may not be removed or altered from any source
 *      distribution.
 *  
 *  
 *  $Id: OptionAlias.cs 19 2007-08-15 13:14:32Z palotas $
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace Plossum.CommandLine
{
    internal class OptionAlias : IOption
    {
        public OptionAlias(string aliasName, Option definingOption)
	    {
            mAliasName = aliasName;
            mDefiningOption = definingOption;
	    }

        public object Value
        {
            set { mDefiningOption.Value = value; }
        }

        public bool RequiresValue
        {
            get { return mDefiningOption.RequiresValue; }
        }

        public bool RequireExplicitAssignment
        {
            get
            {
                return mDefiningOption.RequireExplicitAssignment;
            }
            set
            {
                mDefiningOption.RequireExplicitAssignment = value;
            }
        }

        public C5.ICollection<Option> ProhibitedBy
        {
            get { return mDefiningOption.ProhibitedBy; }
        }

        public OptionGroup Group
        {
            get { return mDefiningOption.Group; }
        }

        public string Name
        {
            get { return mAliasName; }
        }

        public BoolFunction BoolFunction
        {
            get { return mDefiningOption.BoolFunction; }
        }

        public int MaxOccurs
        {
            get { return mDefiningOption.MaxOccurs; }
        }

        public int MinOccurs
        {
            get { return mDefiningOption.MinOccurs; }
        }

        public string Description
        {
            get { return mDefiningOption.Description; }
        }

        public int SetCount
        {
            get
            {
                return mDefiningOption.SetCount;
            }
            set
            {
                mDefiningOption.SetCount = value;
            }
        }

        public bool AcceptsValue
        {
            get { return mDefiningOption.AcceptsValue; }
        }

        public bool HasDefaultValue
        {
            get { return mDefiningOption.HasDefaultValue; }
        }

        public bool IsBooleanType
        {
            get { return mDefiningOption.IsBooleanType; }
        }

        public bool IsAlias
        {
            get { return true; }
        }

        public Option DefiningOption
        {
            get { return mDefiningOption; }
        }

        public void SetDefaultValue()
        {
            mDefiningOption.SetDefaultValue();
        }

        public object MinValue
        {
            get { return mDefiningOption.MinValue; }
        }

        public object MaxValue
        {
            get { return mDefiningOption.MaxValue; }
        }

        private Option mDefiningOption;
        private string mAliasName;

        #region IOption Members


        public bool IsIntegralType
        {
            get { return mDefiningOption.IsIntegralType; }
        }

        public bool IsFloatingPointType
        {
            get { return mDefiningOption.IsFloatingPointType; }
        }

        public bool IsDecimalType
        {
            get { return mDefiningOption.IsDecimalType; }
        }

        public bool IsNumericalType
        {
            get { return mDefiningOption.IsNumericalType; }
        }

        #endregion
    }
}
